package com.example.opengldemo;

import android.content.Context;
import android.opengl.GLES20;
import android.util.Log;

public class ColorShaderProgram extends ShaderProgram {

    private int uMatrixLocation;

    private int aPositionLocation;
    private int aColorLocaiton;

    public ColorShaderProgram(Context context){
        super(context,R.raw.simple_vertex_shader,R.raw.simple_fragment_shader);

        uMatrixLocation = GLES20.glGetUniformLocation(program,U_MATRIX);
        Log.e("androidLog","uMatrixLocation="+uMatrixLocation);

        aPositionLocation = GLES20.glGetAttribLocation(program,A_POSITION);
        Log.e("androidLog","aPositionLocation="+aPositionLocation);

        aColorLocaiton = GLES20.glGetAttribLocation(program,A_COLOR);
        Log.e("androidLog","aColorLocaiton="+aColorLocaiton);
    }

    public void setUniforms(float []matrix){

        GLES20.glUniformMatrix4fv(uMatrixLocation,1,false,matrix,0);
    }

    public int getPositionAttributeLocation(){
        return aPositionLocation;
    }

    public int getColorAttributeLocation(){
        return aColorLocaiton;
    }

}









































